package com.spacex.danhuang.polive.adapters;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.spacex.danhuang.polive.AppDataClass.MsgData;
import com.spacex.danhuang.polive.R;

import java.util.List;

/**
 * Created by Administrator on 2016/6/12 0012.
 */
public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.MsgZoneHolder> {

    private List<MsgData> msgDataList;

    public MsgAdapter(List<MsgData> list) {
        msgDataList = list;
    }

    @Override
    public MsgZoneHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.room_interface_msg_item, parent, false);
        return new MsgZoneHolder(v);
    }

    @Override
    public void onBindViewHolder(MsgZoneHolder holder, int position) {
        MsgData msgData = msgDataList.get(position);
        holder.tv_room_msg_item_nickname.setText(msgData.getNickname());
        holder.tv_room_msg_item_msgbody.setText(msgData.getMsg());
    }

    @Override
    public int getItemCount() {
        return msgDataList.size();
    }

    public class MsgZoneHolder extends RecyclerView.ViewHolder {
        private TextView tv_room_msg_item_nickname;
        private TextView tv_room_msg_item_msgbody;

        public MsgZoneHolder(View itemView) {
            super(itemView);

            tv_room_msg_item_nickname = (TextView)itemView.findViewById(R.id.tv_room_msg_item_nickname);
            tv_room_msg_item_msgbody = (TextView)itemView.findViewById(R.id.tv_room_msg_item_msgbody);
        }
    }
}
